package org.hzero.business.report.builder.director;

import org.hzero.business.report.builder.KnifeReportColumnsBuilder;
import org.hzero.business.report.dto.KnifeReportHeaderColumn;
import org.hzero.business.report.dto.KnifeReportLineColumn;
import org.hzero.business.report.dto.KnifeReportTable;
import org.hzero.business.report.enums.ColumnOrderEnum;

import java.util.List;

/**
 * 报表中介者
 *
 * @author: tianhao.luo@hand-china.com 2021/2/19  17:04
 */
public class KnifeReportTemplateDirector<Header,Line> {
    private final KnifeReportColumnsBuilder reportTemplateColumnsBuilder;


    public KnifeReportTemplateDirector(KnifeReportColumnsBuilder reportTemplateColumnsBuilder) {
        this.reportTemplateColumnsBuilder = reportTemplateColumnsBuilder;
    }

    public KnifeReportTable<Header,Line> build(ColumnOrderEnum headerColumnOrderEnum,ColumnOrderEnum lineColumnOrderEnum, Header header, List<Line> lineList){
        List<KnifeReportHeaderColumn> headerColumnsList = reportTemplateColumnsBuilder.buildHeaderColumns(headerColumnOrderEnum);
        List<KnifeReportLineColumn> lineColumnsList = reportTemplateColumnsBuilder.buildLineColumns(lineColumnOrderEnum);
        return new KnifeReportTable<>(header, headerColumnsList, lineColumnsList, lineList);
    }
}
